﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

namespace Windows8Accelerator.Core.Xaml.Controls.Charts
{
    public class DataSeries : DependencyObject
    {
        public DataSeries()
        {
            Series = new ObservableCollection<IDataSerie>();
        }

        public ObservableCollection<IDataSerie> Series
        {
            get { return (ObservableCollection<IDataSerie>)GetValue(SeriesProperty); }
            set { SetValue(SeriesProperty, value); }
        }
        public static readonly DependencyProperty SeriesProperty =
            DependencyProperty.Register("Series", typeof(ObservableCollection<IDataSerie>), typeof(DataSeries), new PropertyMetadata(null));

        public double GetMinY()
        {
            return Series.Select((s) => s.GetMinY()).Min();
        }

        public double GetMaxY()
        {
            return Series.Select((s) => s.GetMaxY()).Max();
        }

        public double GetMinX()
        {
            return Series.Select((s) => s.GetMinX()).Min();
        }

        public double GetMaxX()
        {
            return Series.Select((s) => s.GetMaxX()).Max();
        }
    }
}
